3.1.52 \(\int (a+b \tan (e+f x)) (c+d \tan (e+f x)) (A+B \tan (e+f x)+C \tan ^2(e+f x)) \, dx\) [52]

3.1.52.1 Optimal result
3.1.52.2 Mathematica [C] (verified)
3.1.52.3 Rubi [A] (verified)
3.1.52.4 Maple [A] (verified)
3.1.52.5 Fricas [A] (verification not implemented)
3.1.52.6 Sympy [B] (verification not implemented)
3.1.52.7 Maxima [A] (verification not implemented)
3.1.52.8 Giac [B] (verification not implemented)
3.1.52.9 Mupad [B] (verification not implemented)

3.1.52.1 Optimal result

Integrand size = 41, antiderivative size = 161 \[ \int (a+b \tan (e+f x)) (c+d \tan (e+f x)) \left (A+B \tan (e+f x)+C \tan ^2(e+f x)\right ) \, dx=(a (A c-c C-B d)-b (B c+(A-C) d)) x-\frac {(A b c+a B c-b c C+a A d-b B d-a C d) \log (\cos (e+f x))}{f}+\frac {(A b+a B-b C) d \tan (e+f x)}{f}-\frac {(b c C-3 b B d-3 a C d) (c+d \tan (e+f x))^2}{6 d^2 f}+\frac {b C \tan (e+f x) (c+d \tan (e+f x))^2}{3 d f} \]

output
(a*(A*c-B*d-C*c)-b*(B*c+(A-C)*d))*x-(A*a*d+A*b*c+B*a*c-B*b*d-C*a*d-C*b*c)* 
ln(cos(f*x+e))/f+(A*b+B*a-C*b)*d*tan(f*x+e)/f-1/6*(-3*B*b*d-3*C*a*d+C*b*c) 
*(c+d*tan(f*x+e))^2/d^2/f+1/3*b*C*tan(f*x+e)*(c+d*tan(f*x+e))^2/d/f
 
3.1.52.2 Mathematica [C] (verified)

Result contains complex when optimal does not.

Time = 1.69 (sec) , antiderivative size = 161, normalized size of antiderivative = 1.00 \[ \int (a+b \tan (e+f x)) (c+d \tan (e+f x)) \left (A+B \tan (e+f x)+C \tan ^2(e+f x)\right ) \, dx=\frac {3 (a+i b) (A+i B-C) (-i c+d) \log (i-\tan (e+f x))+3 (a-i b) (A-i B-C) (i c+d) \log (i+\tan (e+f x))+6 (A b+a B-b C) d \tan (e+f x)+\frac {(-b c C+3 b B d+3 a C d) (c+d \tan (e+f x))^2}{d^2}+\frac {2 b C \tan (e+f x) (c+d \tan (e+f x))^2}{d}}{6 f} \]

input
Integrate[(a + b*Tan[e + f*x])*(c + d*Tan[e + f*x])*(A + B*Tan[e + f*x] + 
C*Tan[e + f*x]^2),x]
 
output
(3*(a + I*b)*(A + I*B - C)*((-I)*c + d)*Log[I - Tan[e + f*x]] + 3*(a - I*b 
)*(A - I*B - C)*(I*c + d)*Log[I + Tan[e + f*x]] + 6*(A*b + a*B - b*C)*d*Ta 
n[e + f*x] + ((-(b*c*C) + 3*b*B*d + 3*a*C*d)*(c + d*Tan[e + f*x])^2)/d^2 + 
 (2*b*C*Tan[e + f*x]*(c + d*Tan[e + f*x])^2)/d)/(6*f)
 
3.1.52.3 Rubi [A] (verified)

Time = 0.74 (sec) , antiderivative size = 174, normalized size of antiderivative = 1.08, number of steps used = 8, number of rules used = 8, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.195, Rules used = {3042, 4120, 3042, 4113, 3042, 4008, 3042, 3956}

Below are the steps used by Rubi to obtain the solution. The rule number used for the transformation is given above next to the arrow. The rules definitions used are listed below.

\(\displaystyle \int (a+b \tan (e+f x)) (c+d \tan (e+f x)) \left (A+B \tan (e+f x)+C \tan ^2(e+f x)\right ) \, dx\)

\(\Big \downarrow \) 3042

\(\displaystyle \int (a+b \tan (e+f x)) (c+d \tan (e+f x)) \left (A+B \tan (e+f x)+C \tan (e+f x)^2\right )dx\)

\(\Big \downarrow \) 4120

\(\displaystyle \frac {b C \tan (e+f x) (c+d \tan (e+f x))^2}{3 d f}-\frac {\int (c+d \tan (e+f x)) \left ((b c C-3 a d C-3 b B d) \tan ^2(e+f x)-3 (A b-C b+a B) d \tan (e+f x)+b c C-3 a A d\right )dx}{3 d}\)

\(\Big \downarrow \) 3042

\(\displaystyle \frac {b C \tan (e+f x) (c+d \tan (e+f x))^2}{3 d f}-\frac {\int (c+d \tan (e+f x)) \left ((b c C-3 a d C-3 b B d) \tan (e+f x)^2-3 (A b-C b+a B) d \tan (e+f x)+b c C-3 a A d\right )dx}{3 d}\)

\(\Big \downarrow \) 4113

\(\displaystyle \frac {b C \tan (e+f x) (c+d \tan (e+f x))^2}{3 d f}-\frac {\int (c+d \tan (e+f x)) (3 (b B-a (A-C)) d-3 (A b-C b+a B) d \tan (e+f x))dx+\frac {(-3 a C d-3 b B d+b c C) (c+d \tan (e+f x))^2}{2 d f}}{3 d}\)

\(\Big \downarrow \) 3042

\(\displaystyle \frac {b C \tan (e+f x) (c+d \tan (e+f x))^2}{3 d f}-\frac {\int (c+d \tan (e+f x)) (3 (b B-a (A-C)) d-3 (A b-C b+a B) d \tan (e+f x))dx+\frac {(-3 a C d-3 b B d+b c C) (c+d \tan (e+f x))^2}{2 d f}}{3 d}\)

\(\Big \downarrow \) 4008

\(\displaystyle \frac {b C \tan (e+f x) (c+d \tan (e+f x))^2}{3 d f}-\frac {-3 d (a A d+a B c-a C d+A b c-b B d-b c C) \int \tan (e+f x)dx+3 d x (-a (A c-B d-c C)+b d (A-C)+b B c)-\frac {3 d^2 \tan (e+f x) (a B+A b-b C)}{f}+\frac {(-3 a C d-3 b B d+b c C) (c+d \tan (e+f x))^2}{2 d f}}{3 d}\)

\(\Big \downarrow \) 3042

\(\displaystyle \frac {b C \tan (e+f x) (c+d \tan (e+f x))^2}{3 d f}-\frac {-3 d (a A d+a B c-a C d+A b c-b B d-b c C) \int \tan (e+f x)dx+3 d x (-a (A c-B d-c C)+b d (A-C)+b B c)-\frac {3 d^2 \tan (e+f x) (a B+A b-b C)}{f}+\frac {(-3 a C d-3 b B d+b c C) (c+d \tan (e+f x))^2}{2 d f}}{3 d}\)

\(\Big \downarrow \) 3956

\(\displaystyle \frac {b C \tan (e+f x) (c+d \tan (e+f x))^2}{3 d f}-\frac {\frac {3 d \log (\cos (e+f x)) (a A d+a B c-a C d+A b c-b B d-b c C)}{f}+3 d x (-a (A c-B d-c C)+b d (A-C)+b B c)-\frac {3 d^2 \tan (e+f x) (a B+A b-b C)}{f}+\frac {(-3 a C d-3 b B d+b c C) (c+d \tan (e+f x))^2}{2 d f}}{3 d}\)

input
Int[(a + b*Tan[e + f*x])*(c + d*Tan[e + f*x])*(A + B*Tan[e + f*x] + C*Tan[ 
e + f*x]^2),x]
 
output
(b*C*Tan[e + f*x]*(c + d*Tan[e + f*x])^2)/(3*d*f) - (3*d*(b*B*c + b*(A - C 
)*d - a*(A*c - c*C - B*d))*x + (3*d*(A*b*c + a*B*c - b*c*C + a*A*d - b*B*d 
 - a*C*d)*Log[Cos[e + f*x]])/f - (3*(A*b + a*B - b*C)*d^2*Tan[e + f*x])/f 
+ ((b*c*C - 3*b*B*d - 3*a*C*d)*(c + d*Tan[e + f*x])^2)/(2*d*f))/(3*d)
 

3.1.52.3.1 Defintions of rubi rules used

rule 3042
Int[u_, x_Symbol] :> Int[DeactivateTrig[u, x], x] /; FunctionOfTrigOfLinear 
Q[u, x]
 

rule 3956
Int[tan[(c_.) + (d_.)*(x_)], x_Symbol] :> Simp[-Log[RemoveContent[Cos[c + d 
*x], x]]/d, x] /; FreeQ[{c, d}, x]
 

rule 4008
Int[((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])*((c_.) + (d_.)*tan[(e_.) + (f_.) 
*(x_)]), x_Symbol] :> Simp[(a*c - b*d)*x, x] + (Simp[b*d*(Tan[e + f*x]/f), 
x] + Simp[(b*c + a*d)   Int[Tan[e + f*x], x], x]) /; FreeQ[{a, b, c, d, e, 
f}, x] && NeQ[b*c - a*d, 0] && NeQ[b*c + a*d, 0]
 

rule 4113
Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_.)*((A_.) + (B_.)*tan[(e_.) 
+ (f_.)*(x_)] + (C_.)*tan[(e_.) + (f_.)*(x_)]^2), x_Symbol] :> Simp[C*((a + 
 b*Tan[e + f*x])^(m + 1)/(b*f*(m + 1))), x] + Int[(a + b*Tan[e + f*x])^m*Si 
mp[A - C + B*Tan[e + f*x], x], x] /; FreeQ[{a, b, e, f, A, B, C, m}, x] && 
NeQ[A*b^2 - a*b*B + a^2*C, 0] &&  !LeQ[m, -1]
 

rule 4120
Int[((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])*((c_.) + (d_.)*tan[(e_.) + (f_.) 
*(x_)])^(n_.)*((A_.) + (B_.)*tan[(e_.) + (f_.)*(x_)] + (C_.)*tan[(e_.) + (f 
_.)*(x_)]^2), x_Symbol] :> Simp[b*C*Tan[e + f*x]*((c + d*Tan[e + f*x])^(n + 
 1)/(d*f*(n + 2))), x] - Simp[1/(d*(n + 2))   Int[(c + d*Tan[e + f*x])^n*Si 
mp[b*c*C - a*A*d*(n + 2) - (A*b + a*B - b*C)*d*(n + 2)*Tan[e + f*x] - (a*C* 
d*(n + 2) - b*(c*C - B*d*(n + 2)))*Tan[e + f*x]^2, x], x], x] /; FreeQ[{a, 
b, c, d, e, f, A, B, C, n}, x] && NeQ[b*c - a*d, 0] && NeQ[c^2 + d^2, 0] && 
  !LtQ[n, -1]
 
3.1.52.4 Maple [A] (verified)

Time = 0.08 (sec) , antiderivative size = 147, normalized size of antiderivative = 0.91

method result size
parts \(\frac {\left (A a d +A b c +B a c \right ) \ln \left (1+\tan \left (f x +e \right )^{2}\right )}{2 f}+\frac {\left (b d B +C a d +C b c \right ) \left (\frac {\tan \left (f x +e \right )^{2}}{2}-\frac {\ln \left (1+\tan \left (f x +e \right )^{2}\right )}{2}\right )}{f}+\frac {\left (A b d +B a d +B b c +C a c \right ) \left (\tan \left (f x +e \right )-\arctan \left (\tan \left (f x +e \right )\right )\right )}{f}+A a c x +\frac {C b d \left (\frac {\tan \left (f x +e \right )^{3}}{3}-\tan \left (f x +e \right )+\arctan \left (\tan \left (f x +e \right )\right )\right )}{f}\) \(147\)
norman \(\left (A a c -A b d -B a d -B b c -C a c +C b d \right ) x +\frac {\left (A b d +B a d +B b c +C a c -C b d \right ) \tan \left (f x +e \right )}{f}+\frac {\left (b d B +C a d +C b c \right ) \tan \left (f x +e \right )^{2}}{2 f}+\frac {C b d \tan \left (f x +e \right )^{3}}{3 f}+\frac {\left (A a d +A b c +B a c -b d B -C a d -C b c \right ) \ln \left (1+\tan \left (f x +e \right )^{2}\right )}{2 f}\) \(151\)
derivativedivides \(\frac {\frac {C \tan \left (f x +e \right )^{3} b d}{3}+\frac {B \tan \left (f x +e \right )^{2} b d}{2}+\frac {C \tan \left (f x +e \right )^{2} a d}{2}+\frac {C \tan \left (f x +e \right )^{2} b c}{2}+A \tan \left (f x +e \right ) b d +B \tan \left (f x +e \right ) a d +B \tan \left (f x +e \right ) b c +C \tan \left (f x +e \right ) a c -\tan \left (f x +e \right ) C b d +\frac {\left (A a d +A b c +B a c -b d B -C a d -C b c \right ) \ln \left (1+\tan \left (f x +e \right )^{2}\right )}{2}+\left (A a c -A b d -B a d -B b c -C a c +C b d \right ) \arctan \left (\tan \left (f x +e \right )\right )}{f}\) \(187\)
default \(\frac {\frac {C \tan \left (f x +e \right )^{3} b d}{3}+\frac {B \tan \left (f x +e \right )^{2} b d}{2}+\frac {C \tan \left (f x +e \right )^{2} a d}{2}+\frac {C \tan \left (f x +e \right )^{2} b c}{2}+A \tan \left (f x +e \right ) b d +B \tan \left (f x +e \right ) a d +B \tan \left (f x +e \right ) b c +C \tan \left (f x +e \right ) a c -\tan \left (f x +e \right ) C b d +\frac {\left (A a d +A b c +B a c -b d B -C a d -C b c \right ) \ln \left (1+\tan \left (f x +e \right )^{2}\right )}{2}+\left (A a c -A b d -B a d -B b c -C a c +C b d \right ) \arctan \left (\tan \left (f x +e \right )\right )}{f}\) \(187\)
parallelrisch \(\frac {2 C \tan \left (f x +e \right )^{3} b d +6 A a c f x -6 A b d f x -6 B a d f x -6 B b c f x +3 B \tan \left (f x +e \right )^{2} b d -6 C a c f x +6 C b d f x +3 C \tan \left (f x +e \right )^{2} a d +3 C \tan \left (f x +e \right )^{2} b c +3 A \ln \left (1+\tan \left (f x +e \right )^{2}\right ) a d +3 A \ln \left (1+\tan \left (f x +e \right )^{2}\right ) b c +6 A \tan \left (f x +e \right ) b d +3 B \ln \left (1+\tan \left (f x +e \right )^{2}\right ) a c -3 B \ln \left (1+\tan \left (f x +e \right )^{2}\right ) b d +6 B \tan \left (f x +e \right ) a d +6 B \tan \left (f x +e \right ) b c -3 C \ln \left (1+\tan \left (f x +e \right )^{2}\right ) a d -3 C \ln \left (1+\tan \left (f x +e \right )^{2}\right ) b c +6 C \tan \left (f x +e \right ) a c -6 \tan \left (f x +e \right ) C b d}{6 f}\) \(252\)
risch \(-B a d x +C b d x +\frac {2 i B a c e}{f}-\frac {2 i B b d e}{f}-\frac {2 i C a d e}{f}-\frac {2 i C b c e}{f}+\frac {2 i A a d e}{f}+\frac {2 i A b c e}{f}+\frac {2 i \left (-3 i C a d \,{\mathrm e}^{2 i \left (f x +e \right )}-3 i B b d \,{\mathrm e}^{4 i \left (f x +e \right )}-3 i C b c \,{\mathrm e}^{2 i \left (f x +e \right )}+3 A b d \,{\mathrm e}^{4 i \left (f x +e \right )}+3 B a d \,{\mathrm e}^{4 i \left (f x +e \right )}+3 B b c \,{\mathrm e}^{4 i \left (f x +e \right )}+3 C a c \,{\mathrm e}^{4 i \left (f x +e \right )}-6 C b d \,{\mathrm e}^{4 i \left (f x +e \right )}-3 i B b d \,{\mathrm e}^{2 i \left (f x +e \right )}-3 i C a d \,{\mathrm e}^{4 i \left (f x +e \right )}-3 i C b c \,{\mathrm e}^{4 i \left (f x +e \right )}+6 A b d \,{\mathrm e}^{2 i \left (f x +e \right )}+6 B a d \,{\mathrm e}^{2 i \left (f x +e \right )}+6 B b c \,{\mathrm e}^{2 i \left (f x +e \right )}+6 C a c \,{\mathrm e}^{2 i \left (f x +e \right )}-6 C b d \,{\mathrm e}^{2 i \left (f x +e \right )}+3 A b d +3 B a d +3 B b c +3 C a c -4 C b d \right )}{3 f \left ({\mathrm e}^{2 i \left (f x +e \right )}+1\right )^{3}}-A b d x -B b c x -C a c x +A a c x -\frac {\ln \left ({\mathrm e}^{2 i \left (f x +e \right )}+1\right ) A a d}{f}-\frac {\ln \left ({\mathrm e}^{2 i \left (f x +e \right )}+1\right ) A b c}{f}-\frac {\ln \left ({\mathrm e}^{2 i \left (f x +e \right )}+1\right ) B a c}{f}+\frac {\ln \left ({\mathrm e}^{2 i \left (f x +e \right )}+1\right ) b d B}{f}+\frac {\ln \left ({\mathrm e}^{2 i \left (f x +e \right )}+1\right ) C a d}{f}+\frac {\ln \left ({\mathrm e}^{2 i \left (f x +e \right )}+1\right ) C b c}{f}-i B b d x -i C a d x -i C b c x +i A a d x +i A b c x +i B a c x\) \(530\)

input
int((a+b*tan(f*x+e))*(c+d*tan(f*x+e))*(A+B*tan(f*x+e)+C*tan(f*x+e)^2),x,me 
thod=_RETURNVERBOSE)
 
output
1/2*(A*a*d+A*b*c+B*a*c)/f*ln(1+tan(f*x+e)^2)+(B*b*d+C*a*d+C*b*c)/f*(1/2*ta 
n(f*x+e)^2-1/2*ln(1+tan(f*x+e)^2))+(A*b*d+B*a*d+B*b*c+C*a*c)/f*(tan(f*x+e) 
-arctan(tan(f*x+e)))+A*a*c*x+C*b*d/f*(1/3*tan(f*x+e)^3-tan(f*x+e)+arctan(t 
an(f*x+e)))
 
3.1.52.5 Fricas [A] (verification not implemented)

Time = 0.26 (sec) , antiderivative size = 150, normalized size of antiderivative = 0.93 \[ \int (a+b \tan (e+f x)) (c+d \tan (e+f x)) \left (A+B \tan (e+f x)+C \tan ^2(e+f x)\right ) \, dx=\frac {2 \, C b d \tan \left (f x + e\right )^{3} + 6 \, {\left ({\left ({\left (A - C\right )} a - B b\right )} c - {\left (B a + {\left (A - C\right )} b\right )} d\right )} f x + 3 \, {\left (C b c + {\left (C a + B b\right )} d\right )} \tan \left (f x + e\right )^{2} - 3 \, {\left ({\left (B a + {\left (A - C\right )} b\right )} c + {\left ({\left (A - C\right )} a - B b\right )} d\right )} \log \left (\frac {1}{\tan \left (f x + e\right )^{2} + 1}\right ) + 6 \, {\left ({\left (C a + B b\right )} c + {\left (B a + {\left (A - C\right )} b\right )} d\right )} \tan \left (f x + e\right )}{6 \, f} \]

input
integrate((a+b*tan(f*x+e))*(c+d*tan(f*x+e))*(A+B*tan(f*x+e)+C*tan(f*x+e)^2 
),x, algorithm="fricas")
 
output
1/6*(2*C*b*d*tan(f*x + e)^3 + 6*(((A - C)*a - B*b)*c - (B*a + (A - C)*b)*d 
)*f*x + 3*(C*b*c + (C*a + B*b)*d)*tan(f*x + e)^2 - 3*((B*a + (A - C)*b)*c 
+ ((A - C)*a - B*b)*d)*log(1/(tan(f*x + e)^2 + 1)) + 6*((C*a + B*b)*c + (B 
*a + (A - C)*b)*d)*tan(f*x + e))/f
 
3.1.52.6 Sympy [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 326 vs. \(2 (148) = 296\).

Time = 0.15 (sec) , antiderivative size = 326, normalized size of antiderivative = 2.02 \[ \int (a+b \tan (e+f x)) (c+d \tan (e+f x)) \left (A+B \tan (e+f x)+C \tan ^2(e+f x)\right ) \, dx=\begin {cases} A a c x + \frac {A a d \log {\left (\tan ^{2}{\left (e + f x \right )} + 1 \right )}}{2 f} + \frac {A b c \log {\left (\tan ^{2}{\left (e + f x \right )} + 1 \right )}}{2 f} - A b d x + \frac {A b d \tan {\left (e + f x \right )}}{f} + \frac {B a c \log {\left (\tan ^{2}{\left (e + f x \right )} + 1 \right )}}{2 f} - B a d x + \frac {B a d \tan {\left (e + f x \right )}}{f} - B b c x + \frac {B b c \tan {\left (e + f x \right )}}{f} - \frac {B b d \log {\left (\tan ^{2}{\left (e + f x \right )} + 1 \right )}}{2 f} + \frac {B b d \tan ^{2}{\left (e + f x \right )}}{2 f} - C a c x + \frac {C a c \tan {\left (e + f x \right )}}{f} - \frac {C a d \log {\left (\tan ^{2}{\left (e + f x \right )} + 1 \right )}}{2 f} + \frac {C a d \tan ^{2}{\left (e + f x \right )}}{2 f} - \frac {C b c \log {\left (\tan ^{2}{\left (e + f x \right )} + 1 \right )}}{2 f} + \frac {C b c \tan ^{2}{\left (e + f x \right )}}{2 f} + C b d x + \frac {C b d \tan ^{3}{\left (e + f x \right )}}{3 f} - \frac {C b d \tan {\left (e + f x \right )}}{f} & \text {for}\: f \neq 0 \\x \left (a + b \tan {\left (e \right )}\right ) \left (c + d \tan {\left (e \right )}\right ) \left (A + B \tan {\left (e \right )} + C \tan ^{2}{\left (e \right )}\right ) & \text {otherwise} \end {cases} \]

input
integrate((a+b*tan(f*x+e))*(c+d*tan(f*x+e))*(A+B*tan(f*x+e)+C*tan(f*x+e)** 
2),x)
 
output
Piecewise((A*a*c*x + A*a*d*log(tan(e + f*x)**2 + 1)/(2*f) + A*b*c*log(tan( 
e + f*x)**2 + 1)/(2*f) - A*b*d*x + A*b*d*tan(e + f*x)/f + B*a*c*log(tan(e 
+ f*x)**2 + 1)/(2*f) - B*a*d*x + B*a*d*tan(e + f*x)/f - B*b*c*x + B*b*c*ta 
n(e + f*x)/f - B*b*d*log(tan(e + f*x)**2 + 1)/(2*f) + B*b*d*tan(e + f*x)** 
2/(2*f) - C*a*c*x + C*a*c*tan(e + f*x)/f - C*a*d*log(tan(e + f*x)**2 + 1)/ 
(2*f) + C*a*d*tan(e + f*x)**2/(2*f) - C*b*c*log(tan(e + f*x)**2 + 1)/(2*f) 
 + C*b*c*tan(e + f*x)**2/(2*f) + C*b*d*x + C*b*d*tan(e + f*x)**3/(3*f) - C 
*b*d*tan(e + f*x)/f, Ne(f, 0)), (x*(a + b*tan(e))*(c + d*tan(e))*(A + B*ta 
n(e) + C*tan(e)**2), True))
 
3.1.52.7 Maxima [A] (verification not implemented)

Time = 0.40 (sec) , antiderivative size = 151, normalized size of antiderivative = 0.94 \[ \int (a+b \tan (e+f x)) (c+d \tan (e+f x)) \left (A+B \tan (e+f x)+C \tan ^2(e+f x)\right ) \, dx=\frac {2 \, C b d \tan \left (f x + e\right )^{3} + 3 \, {\left (C b c + {\left (C a + B b\right )} d\right )} \tan \left (f x + e\right )^{2} + 6 \, {\left ({\left ({\left (A - C\right )} a - B b\right )} c - {\left (B a + {\left (A - C\right )} b\right )} d\right )} {\left (f x + e\right )} + 3 \, {\left ({\left (B a + {\left (A - C\right )} b\right )} c + {\left ({\left (A - C\right )} a - B b\right )} d\right )} \log \left (\tan \left (f x + e\right )^{2} + 1\right ) + 6 \, {\left ({\left (C a + B b\right )} c + {\left (B a + {\left (A - C\right )} b\right )} d\right )} \tan \left (f x + e\right )}{6 \, f} \]

input
integrate((a+b*tan(f*x+e))*(c+d*tan(f*x+e))*(A+B*tan(f*x+e)+C*tan(f*x+e)^2 
),x, algorithm="maxima")
 
output
1/6*(2*C*b*d*tan(f*x + e)^3 + 3*(C*b*c + (C*a + B*b)*d)*tan(f*x + e)^2 + 6 
*(((A - C)*a - B*b)*c - (B*a + (A - C)*b)*d)*(f*x + e) + 3*((B*a + (A - C) 
*b)*c + ((A - C)*a - B*b)*d)*log(tan(f*x + e)^2 + 1) + 6*((C*a + B*b)*c + 
(B*a + (A - C)*b)*d)*tan(f*x + e))/f
 
3.1.52.8 Giac [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 2475 vs. \(2 (157) = 314\).

Time = 1.79 (sec) , antiderivative size = 2475, normalized size of antiderivative = 15.37 \[ \int (a+b \tan (e+f x)) (c+d \tan (e+f x)) \left (A+B \tan (e+f x)+C \tan ^2(e+f x)\right ) \, dx=\text {Too large to display} \]

input
integrate((a+b*tan(f*x+e))*(c+d*tan(f*x+e))*(A+B*tan(f*x+e)+C*tan(f*x+e)^2 
),x, algorithm="giac")
 
output
1/6*(6*A*a*c*f*x*tan(f*x)^3*tan(e)^3 - 6*C*a*c*f*x*tan(f*x)^3*tan(e)^3 - 6 
*B*b*c*f*x*tan(f*x)^3*tan(e)^3 - 6*B*a*d*f*x*tan(f*x)^3*tan(e)^3 - 6*A*b*d 
*f*x*tan(f*x)^3*tan(e)^3 + 6*C*b*d*f*x*tan(f*x)^3*tan(e)^3 - 3*B*a*c*log(4 
*(tan(f*x)^2*tan(e)^2 - 2*tan(f*x)*tan(e) + 1)/(tan(f*x)^2*tan(e)^2 + tan( 
f*x)^2 + tan(e)^2 + 1))*tan(f*x)^3*tan(e)^3 - 3*A*b*c*log(4*(tan(f*x)^2*ta 
n(e)^2 - 2*tan(f*x)*tan(e) + 1)/(tan(f*x)^2*tan(e)^2 + tan(f*x)^2 + tan(e) 
^2 + 1))*tan(f*x)^3*tan(e)^3 + 3*C*b*c*log(4*(tan(f*x)^2*tan(e)^2 - 2*tan( 
f*x)*tan(e) + 1)/(tan(f*x)^2*tan(e)^2 + tan(f*x)^2 + tan(e)^2 + 1))*tan(f* 
x)^3*tan(e)^3 - 3*A*a*d*log(4*(tan(f*x)^2*tan(e)^2 - 2*tan(f*x)*tan(e) + 1 
)/(tan(f*x)^2*tan(e)^2 + tan(f*x)^2 + tan(e)^2 + 1))*tan(f*x)^3*tan(e)^3 + 
 3*C*a*d*log(4*(tan(f*x)^2*tan(e)^2 - 2*tan(f*x)*tan(e) + 1)/(tan(f*x)^2*t 
an(e)^2 + tan(f*x)^2 + tan(e)^2 + 1))*tan(f*x)^3*tan(e)^3 + 3*B*b*d*log(4* 
(tan(f*x)^2*tan(e)^2 - 2*tan(f*x)*tan(e) + 1)/(tan(f*x)^2*tan(e)^2 + tan(f 
*x)^2 + tan(e)^2 + 1))*tan(f*x)^3*tan(e)^3 - 18*A*a*c*f*x*tan(f*x)^2*tan(e 
)^2 + 18*C*a*c*f*x*tan(f*x)^2*tan(e)^2 + 18*B*b*c*f*x*tan(f*x)^2*tan(e)^2 
+ 18*B*a*d*f*x*tan(f*x)^2*tan(e)^2 + 18*A*b*d*f*x*tan(f*x)^2*tan(e)^2 - 18 
*C*b*d*f*x*tan(f*x)^2*tan(e)^2 + 3*C*b*c*tan(f*x)^3*tan(e)^3 + 3*C*a*d*tan 
(f*x)^3*tan(e)^3 + 3*B*b*d*tan(f*x)^3*tan(e)^3 + 9*B*a*c*log(4*(tan(f*x)^2 
*tan(e)^2 - 2*tan(f*x)*tan(e) + 1)/(tan(f*x)^2*tan(e)^2 + tan(f*x)^2 + tan 
(e)^2 + 1))*tan(f*x)^2*tan(e)^2 + 9*A*b*c*log(4*(tan(f*x)^2*tan(e)^2 - ...
 
3.1.52.9 Mupad [B] (verification not implemented)

Time = 8.42 (sec) , antiderivative size = 153, normalized size of antiderivative = 0.95 \[ \int (a+b \tan (e+f x)) (c+d \tan (e+f x)) \left (A+B \tan (e+f x)+C \tan ^2(e+f x)\right ) \, dx=\frac {\ln \left ({\mathrm {tan}\left (e+f\,x\right )}^2+1\right )\,\left (\frac {A\,a\,d}{2}+\frac {A\,b\,c}{2}+\frac {B\,a\,c}{2}-\frac {B\,b\,d}{2}-\frac {C\,a\,d}{2}-\frac {C\,b\,c}{2}\right )}{f}-x\,\left (A\,b\,d-A\,a\,c+B\,a\,d+B\,b\,c+C\,a\,c-C\,b\,d\right )+\frac {{\mathrm {tan}\left (e+f\,x\right )}^2\,\left (\frac {B\,b\,d}{2}+\frac {C\,a\,d}{2}+\frac {C\,b\,c}{2}\right )}{f}+\frac {\mathrm {tan}\left (e+f\,x\right )\,\left (A\,b\,d+B\,a\,d+B\,b\,c+C\,a\,c-C\,b\,d\right )}{f}+\frac {C\,b\,d\,{\mathrm {tan}\left (e+f\,x\right )}^3}{3\,f} \]

input
int((a + b*tan(e + f*x))*(c + d*tan(e + f*x))*(A + B*tan(e + f*x) + C*tan( 
e + f*x)^2),x)
 
output
(log(tan(e + f*x)^2 + 1)*((A*a*d)/2 + (A*b*c)/2 + (B*a*c)/2 - (B*b*d)/2 - 
(C*a*d)/2 - (C*b*c)/2))/f - x*(A*b*d - A*a*c + B*a*d + B*b*c + C*a*c - C*b 
*d) + (tan(e + f*x)^2*((B*b*d)/2 + (C*a*d)/2 + (C*b*c)/2))/f + (tan(e + f* 
x)*(A*b*d + B*a*d + B*b*c + C*a*c - C*b*d))/f + (C*b*d*tan(e + f*x)^3)/(3* 
f)